when deleting a folder starts by making it read-write permissions
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 4 Apr 2025 14:37:11 +0000 (16:37 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 7 Apr 2025 10:53:38 +0000 (10:53 +0000)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/filesystem.cpp
src/libsync/propagatorjobs.cpp

index ecf950fe34e2cbde25d5c6546b85475dd272ab83..5b719bd8be645d257b95e64ffc19f108593e4510 100644 (file)
@@ -259,6 +259,8 @@ qint64 FileSystem::getSize(const QString &filename)
 // Code inspired from Qt5's QDir::removeRecursively
 bool FileSystem::removeRecursively(const QString &path, const std::function<void(const QString &path, bool isDir)> &onDeleted, QStringList *errors)
 {
+    FileSystem::setFolderPermissions(path, FileSystem::FolderPermissions::ReadWrite);
+
     bool allRemoved = true;
     QDirIterator di(path, QDir::AllEntries | QDir::Hidden | QDir::System | QDir::NoDotAndDotDot);
 
index b1d85e198989d1af624b67f10332ba0239a72420..a443d84547988323c51a23afa7858fd3917f1b4b 100644 (file)
@@ -63,7 +63,6 @@ bool PropagateLocalRemove::removeRecursively(const QString &path)
     const auto fileInfo = QFileInfo{absolute};
     const auto parentFolderPath = fileInfo.dir().absolutePath();
     const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
-    FileSystem::setFolderPermissions(absolute, FileSystem::FolderPermissions::ReadWrite);
     bool success = FileSystem::removeRecursively(
         absolute,
         [&deleted](const QString &path, bool isDir) {